<% if @file %>
  $('.content-header h1').html('<%= escape_javascript t('generated_files.complete_heading') %>');
  $('#build_loading').html('<%= escape_javascript t('generated_files.complete_message') %>');
  // make a regular http request to get the file
  location.reload();
<% elsif params[:count].to_i * 10 > GeneratedFile::MAX_WAIT_SECONDS %>
  $('.content-header h1').html('<%= escape_javascript t('generated_files.failure_heading') %>');
  $('#build_loading').html('<%= escape_javascript t('generated_files.failure_message') %>');
<% else %>
  function load() {
    $.get('<%= escape_javascript generated_file_path(params[:id], format: :js, count: params[:count].to_i+1) %>');
  }
  setTimeout(load, 10000);
<% end %>
